<?php
namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use App\Models\Qiniu;

class CommentController extends Controller
{
	public function __construct()
	{

	}

	/*
        状态码
        number       message
        200          成功
        300          数据库操作失败
        301          不允许操作
        305          参数错误
        306          操作无效    
        307          上传失败
        406          找不到文件
    */

	protected function json_success($message,$da='',$code='200')
    {
        $data = [
            'code'=>$code,                                  //
            'data'=>$da,                                    //数据
            'resultCode'=>true,                            //返回码
            'message'=>$message                             //提示
        ];
        return response()->json($data);
    }

    protected function json_error($message,$da='',$code='300')
    {
        $data = [
            'code'=>$code,                                  //
            'data'=>$da,                                    //数据
            'resultCode'=>true,                            //返回码
            'message'=>$message                             //提示
        ];
        return response()->json($data);
    }

    protected function returnJson($data)
    {
        return response()->json($data);
    }

    protected function curl($url)
    {
         $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        if(curl_errno($ch))
        { echo 'CURL ERROR Code: '.curl_errno($ch).', reason: '.curl_error($ch);}
        curl_close($ch);
        $info = json_decode($output, true);
        return $info;
    }

    public function getSessionData()
    {
        $data = session("fyback_info");
        return $data;
    }
}